home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
amok_lha
/
amok13.lha
/
XHair
/
Gummi.mod
< prev
next >
Wrap
Text File
|
1993-08-15
|
9KB
|
324 lines
(*---------------------------------------------------------------------------
:Program. Gummi.mod
:Author. Fridtjof Siebert
:Address. Nobileweg 67, D-7-Stgt-40
:Phone. (0)711/822509
:Shortcut. [fbs]
:Version. 1.0
:Date. 03-Jan-89
:Copyright. PD
:Language. Modula-II
:Translator. M2Amiga v3.1d
:Imports. arp.library
:Contents. Program to replace Mousepointer by some lines
:Usage. Gummi [HELP] [QUIT] [COL HHH] [OLDPTR]
---------------------------------------------------------------------------*)
MODULE Gummi;
FROM SYSTEM IMPORT ADR, ADDRESS, LONGSET;
FROM Arts IMPORT Assert, TermProcedure, wbStarted, dosCmdBuf, dosCmdLen,
Terminate;
FROM Intuition IMPORT GetPrefs, ScreenPtr, MakeScreen,
RethinkDisplay, Preferences, NewWindow, WindowFlags,
WindowFlagSet, ScreenFlags, CloseWindow, ScreenFlagSet,
IDCMPFlags, IDCMPFlagSet, OpenWindow, WindowPtr,
SetPrefs;
FROM ARP IMPORT ArpAlloc, CreatePort, Puts, GADS, ArpAllocMem, Delay,
DeletePort;
FROM Dos IMPORT ctrlC;
FROM Exec IMPORT Forbid, Permit, FindPort, MsgPortPtr, NodeType,
Message, MessagePtr, GetMsg, ReplyMsg, PutMsg, Wait,
MemReqs, MemReqSet, WaitPort, FindTask, SetTaskPri;
FROM Graphics IMPORT WaitBOVP, BitMap, Move, Draw, SetDrMd, DrawModes,
DrawModeSet, WaitTOF, LayerInfoPtr, RastPortPtr,
LayerPtr;
FROM Layers IMPORT NewLayerInfo, CreateUpfrontLayer, DeleteLayer,
DisposeLayerInfo;
(*------ CONSTS: ------*)
CONST
WindowTitle = "XHair © Fridtjof Siebert";
PortName = "NewWBPlanes[fbs].Port";
ReplyName = "NewWBPlanes[fbs].ReplyPort";
TPlate = "HELP/S,QUIT/S,COL/K,OLDPTR/S";
LTRUE = -1;
LFALSE = 0;
(*------ TYPES: ------*)
TYPE
ColorMap = ARRAY[0..31] OF INTEGER;
LONGBOOL = LONGINT;
(*------ VARS: ------*)
VAR
WBScreen: ScreenPtr;
NewPlane: ADDRESS;
Prefs, NewPrefs: Preferences;
CMap: ColorMap;
OldColTable: POINTER TO ColorMap;
XHairColor: INTEGER;
Window: WindowPtr;
NuWindow: NewWindow;
MyMsg: Message;
QuitMessage,Msg: MessagePtr;
MyPort, OldPort: MsgPortPtr;
Args: RECORD
help: LONGBOOL;
quit: LONGBOOL;
col: POINTER TO ARRAY[0..79] OF CHAR;
oldptr: LONGBOOL;
END;
OldPtr: BOOLEAN;
NumArgs: INTEGER;
i: INTEGER;
oldx,oldy,x,y: INTEGER;
rp: RastPortPtr;
bm: BitMap;
count: CARDINAL;
dmacon[0DFF096H]: CARDINAL;
li: LayerInfoPtr;
layer: LayerPtr;
(*------ CleanUp: ------*)
PROCEDURE CleanUp();
BEGIN
(*------ Remove Layer: ------*)
IF layer#NIL THEN IF DeleteLayer(layer)=NIL THEN END END;
IF li#NIL THEN DisposeLayerInfo(li) END;
(*------ Remove Picture from WB: ------*)
IF WBScreen#NIL THEN
Forbid();
IF OldColTable#NIL THEN
WBScreen^.viewPort.colorMap^.colorTable := OldColTable;
END;
WITH WBScreen^.bitMap DO
depth := 2;
planes[2] := NIL;
END;
MakeScreen(WBScreen);
Permit();
RethinkDisplay();
END;
(*------ Reset Preferences: ------*)
IF NOT(OldPtr) AND (Prefs.fontHeight>0) THEN
SetPrefs(ADR(Prefs),SIZE(Preferences),TRUE);
WaitPort(Window^.userPort);
END;
(*------ Close everything: ------*)
IF Window#NIL THEN CloseWindow(Window); END;
(*------ Remove Port: ------*)
IF MyPort#NIL THEN
Forbid();
IF QuitMessage=NIL THEN QuitMessage := GetMsg(MyPort) END;
WHILE QuitMessage#NIL DO
ReplyMsg(QuitMessage);
QuitMessage := GetMsg(MyPort);
END;
DeletePort(MyPort);
Permit();
END;
END CleanUp;
(*------ MAIN: ------*)
BEGIN
(*------ Initialization: ------*)
WBScreen := NIL; OldColTable := NIL; Window := NIL; MyPort := NIL;
Prefs.fontHeight := 0; layer := NIL; li := NIL;
TermProcedure(CleanUp);
IF SetTaskPri(FindTask(NIL),5)=0 THEN END;
(*------ Have we already been started? ------*)
OldPort := FindPort(ADR(PortName));
IF OldPort#NIL THEN
MyPort := CreatePort(ADR(ReplyName),0);
Assert(MyPort#NIL,ADR("CreatePort failed"));
MyMsg.node.type := message;
MyMsg.replyPort := MyPort;
PutMsg(OldPort,ADR(MyMsg)); (* Signal task to quit *)
WaitPort(MyPort);
DeletePort(MyPort);
MyPort := NIL;
IF wbStarted THEN
Terminate(0);
ELSE
IF Puts(ADR("Task signalled"))=0 THEN END;
END;
END;
MyPort := CreatePort(ADR(PortName),0);
Assert(MyPort#NIL,ADR("CreatePort failed"));
(*------ Open Window: ------*)
WITH NuWindow DO
leftEdge := 0; topEdge := 0;
width := 1; height := 1;
detailPen := 0; blockPen := 1;
idcmpFlags := IDCMPFlagSet{newPrefs};
flags := WindowFlagSet{backDrop};
firstGadget:= NIL; checkMark := NIL;
title := ADR(WindowTitle);
screen := NIL; bitMap := NIL;
type := ScreenFlagSet{wbenchScreen};
END;
Window := OpenWindow(NuWindow);
Assert(Window#NIL,ADR("Can't open Window!!!"));
WBScreen := Window^.wScreen;
IF WBScreen^.bitMap.depth>2 THEN
IF Puts(ADR("There's something strange with your Workbench!"))=0 THEN END;
Terminate(0);
END;
(*------ Get Arguments: ------*)
XHairColor := -1; OldPtr := FALSE;
IF NOT wbStarted THEN
WITH Args DO
help := LFALSE;
quit := LFALSE;
col := NIL;
oldptr := LFALSE;
END;
NumArgs := GADS(dosCmdBuf,dosCmdLen,NIL,ADR(Args),ADR(TPlate));
WITH Args DO
IF (NumArgs=-1) THEN
IF Puts(ADR("Bad Args"))=0 THEN END;
Terminate(0);
END;
IF help=LTRUE THEN
IF Puts(ADR("Usage: Gummi [HELP] [QUIT] [COL HHH] [OLDPTR]")) +
Puts(ADR(" HELP Shows usage")) +
Puts(ADR(" QUIT Signals Gummi to quit")) +
Puts(ADR(" COL HHH Set pointer's color to hex # HHH")) +
Puts(ADR(" OLDPTR Aviods removing pointer"))=0 THEN END;
Terminate(0);
END;
IF quit=LTRUE THEN Terminate(0) END;
IF (col#NIL) THEN
XHairColor := 0;
IF col^[3]#0C THEN
IF Puts(ADR("Bad Args"))=0 THEN END;
Terminate(0);
END;
FOR i:=0 TO 2 DO
XHairColor := XHairColor * 16;
CASE CAP(col^[i]) OF
"0".."9": INC(XHairColor,ORD( col^[i] )-ORD("0") ); |
"A".."F": INC(XHairColor,ORD(CAP(col^[i]))-ORD("A")+10); |
ELSE
IF Puts(ADR("Bad Args"))=0 THEN END;
Terminate(0);
END;
END;
END;
OldPtr := (oldptr=LTRUE);
END;
END;
(*------ Modify Preferences: ------*)
IF NOT OldPtr THEN
GetPrefs(ADR(Prefs),SIZE(Preferences));
NewPrefs := Prefs;
WITH NewPrefs DO
FOR i:=2 TO 33 DO
pointerMatrix[i] := 0;
END;
color17 := color0;
color18 := color0;
color19 := color0;
END;
SetPrefs(ADR(NewPrefs),SIZE(Preferences),TRUE);
END;
(*------ Set Colors: ------*)
Forbid();
OldColTable := WBScreen^.viewPort.colorMap^.colorTable;
CMap := OldColTable^;
IF XHairColor=-1 THEN
FOR i:=0 TO 3 DO CMap[4+i]:=CMap[3-i] END;
ELSE
FOR i:=4 TO 7 DO CMap[i]:=XHairColor END;
END;
WBScreen^.viewPort.colorMap^.colorTable := ADR(CMap);
Permit();
(*------ Add Plane to WBScreen: ------*)
WITH WBScreen^.bitMap DO
NewPlane := ArpAllocMem(rows*bytesPerRow,MemReqSet{chip,memClear});
Assert(NewPlane#NIL,ADR("Out of memory"));
planes[2] := NewPlane;
END;
(*------ Init Layer: ------*)
WITH WBScreen^ DO
bm := WBScreen^.bitMap;
bm.depth := 1;
bm.planes[0] := NewPlane;
li := NewLayerInfo();
Assert(li#NIL,ADR("NewLayerInfo() failed."));
layer := CreateUpfrontLayer(li,ADR(bm),0,0,width-1,height-1,LONGSET{0},NIL);
Assert(li#NIL,ADR("CreateUpfrontLayer() failed."));
rp := layer^.rp;
SetDrMd(rp,DrawModeSet{complement});
(*------ Do it: ------*)
WITH bitMap DO
count := 0; oldx := -1000;
REPEAT
WaitTOF();
IF NOT OldPtr THEN dmacon := 32 END;
x := mouseX; y := mouseY;
INC(count);
IF (count=50) THEN
Forbid();
depth := 3;
MakeScreen(WBScreen);
depth := 2;
RethinkDisplay();
Permit();
count := 0;
END;
IF (oldx#x) OR (oldy#y) THEN
WITH WBScreen^ DO
Move(rp,0,0); Draw(rp, x, y); Draw(rp,width-1,height-1);
Move(rp,width-1,0); Draw(rp, x, y); Draw(rp,0,height-1);
IF oldx#-1000 THEN
Move(rp,0,0); Draw(rp,oldx,oldy); Draw(rp,width-1,height-1);
Move(rp,width-1,0); Draw(rp,oldx,oldy); Draw(rp,0,height-1);
END;
END;
END;
oldx := x; oldy := y;
QuitMessage := GetMsg(MyPort);
UNTIL QuitMessage#NIL;
END;
END;
END Gummi.